package com.um.jdy.mp.order.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import com.um.jdy.mp.order.entity.vo.StationOrderSummaryListVO;
import com.um.jdy.mp.order.entity.vo.OrderDetailVO;
import com.um.jdy.mp.order.entity.vo.OrderItemVO;
import com.um.jdy.mp.order.entity.vo.StationOrderSummaryVO;
import com.um.jdy.mp.order.manager.ChargeOrderManager;
import com.um.springboot.starter.entity.Page;
import com.um.springboot.starter.orm.controller.BaseController;
import com.um.springboot.starter.orm.entity.Response;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;


@Api(tags = "订单管理")
@Validated
@RestController
@RequestMapping("/api/v1/cms/order")
@SaCheckLogin
public class ChargeOrderController extends BaseController<ChargeOrderManager> {

    @ApiOperation(value = "分页查询订单")
    @GetMapping("page")
    public Response<Page<OrderItemVO>> getOrderPage(@ApiParam(value = "页码") @NotNull Integer page_no,
                                                @ApiParam(value = "数据量") @NotNull Integer page_size,
                                                @ApiParam(value = "订单状态") String order_status,
                                                @ApiParam(value = "订单号") String order_no) {
        return manager.page(page_no,page_size,order_status,order_no);
    }

    @ApiOperation(value = "查询订单")
    @GetMapping("{id}")
    public Response<OrderDetailVO> getOrder(@ApiParam(value = "订单ID") @PathVariable @NotNull String id) {
        return manager.get(id);
    }


    /**
     * 订单统计
     * @return
     */
    @ApiOperation(value = "订单统计")
    @GetMapping("station/summary")
    public Response<StationOrderSummaryVO> getStationOrderSummary() {
        return Response.success(manager.getStationOrderSummary());
    }

    /**
     * 网点订单统计
     * @return
     */
    @ApiOperation(value = "网点订单统计")
    @GetMapping("station/list")
    public Response<StationOrderSummaryListVO> getStationOrderSummaryList(@ApiParam(value = "网点ID") String id,
                                                                          @ApiParam(value = "类型：年份-year 月份-month") @NotNull String type,
                                                                          @ApiParam(value = "年份或月份") @NotNull String year_or_month) {
        return Response.success(manager.getStationOrderSummaryList(id,type,year_or_month.trim()));
    }

}
